var removeAnagrams = function(words) {
  const maps = new Array(words.length).fill(0).map(_ => new Array(26).fill(0));
  const base = 'a'.charCodeAt(0);
  words.forEach((w,i) => {
      for(let c in w) {
         maps[i][w.charCodeAt(c) - base]++;     
      }
  });
  const ret = [words[0]];
  let last = 0;
  const judge = (i, j) => {
      return maps[i].every((n, x) => n === maps[j][x]);
  }
  for(let i = 1; i< words.length; i++) {
      if(!judge(i, last)) {
          last = i;
          ret.push(words[i]);
      }    
  }
  return ret;
};